package io.renren.modules.canteens.dao;

import io.renren.common.dao.BaseDao;
import io.renren.modules.canteens.dto.StockOrdermxDTO;
import io.renren.modules.canteens.entity.StockOrdermxEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 食材采购明细表
 *
 * @author 翟文闯 619556390@QQ.com
 * @since 1.0.0 2019-11-22
 */
@Mapper
public interface StockOrdermxDao extends BaseDao<StockOrdermxEntity> {
    @Select("SELECT A.* from  canteens_stock_ordermx A where A.stock_order_id = '${stockOrderId}' GROUP BY A.supplier_id  ")
    List<StockOrdermxDTO> getsupplierOrder(long stockOrderId);
    @Select("SELECT (select B.supplier_name from canteens_supplier B where A.supplier_id = B.supplier_id ) as supplier_name, " +
            " (select B.unit from canteens_food B where A.food_id = B.food_id ) as unit, " +
            " (select B.food_name from canteens_food B where A.food_id = B.food_id ) as food_name, " +
            " C.meal_time,A.* from  canteens_stock_ordermx A ,canteens_stock_order C" +
            " where A.stock_order_id = c.stock_order_id and  A.stock_order_id = '${stockOrderId}' and  A.supplier_id = '${supplierId}' ")
    List<StockOrdermxDTO> getOrderMx(long stockOrderId,long supplierId );
    @Select("SELECT sum(unit_price*arrival_num) as totalPrice from  canteens_stock_ordermx where stock_order_id = '${stockOrderId}' and  supplier_id = '${supplierId}' ")
    StockOrdermxDTO getTotalPrice(long stockOrderId,long supplierId );
    @Select("SELECT sum(unit_price*arrival_num) as totalPrice from  canteens_stock_ordermx where stock_order_id = '${stockOrderId}'  ")
    StockOrdermxDTO getTotalMony(long stockOrderId);
}